package payroll.trans;

import payroll.Employee;
import payroll.PayrollDatabase;
import payroll.Transaction;
import payroll.exception.NoSuchEmployeeException;

public class DeleteEmployeeTransaction implements Transaction {

    private int empId;
    private Employee e;

    public DeleteEmployeeTransaction(int empId) {
    this.empId = empId;
    }

    @Override
    public void execute() {
    Employee e = PayrollDatabase.getEmployee(empId);
    if(e != null) {
        PayrollDatabase.deleteEmployee(empId);
    }else {
        throw new NoSuchEmployeeException();
    }

}
}
